<template>
    <vue-ueditor-wrap v-model="context" :config="myConfig" @ready="ueditorReady" ref="ue2" mode="observer"
        :observerDebounceTime="100" :observerOptions="{ attributes: true, characterData: true, childList: true, subtree: true }"></vue-ueditor-wrap>
</template>

<script>
    export default {
        data() {
            return {
                tableData: [],
                hidePage: false,
                page: {
                    pageNo: 1,
                    pageSize: 10,
                    total: null
                },
                title: '新增页面',
                addPage: false,
                updateForm: {
                    id: null,
                    title: ''
                },
                ueditor: '',
                context: '',
                myConfig: {
                    // 如果需要上传功能,找后端小伙伴要服务器接口地址/ueditor/exec
                    // serverUrl: '/exc/ueditor/exec', //本地
                    serverUrl: this.$axios.baseUrl + '/ueditor/exec', //线上
                    // serverUrl: '/exc/ueditor/exec',
                    // serverUrl: 'http://35.201.165.105:8000/controller.php',
                    // 你的UEditor资源存放的路径,相对于打包后的index.html
                    UEDITOR_HOME_URL: '/static/UEditor/',
                    // 编辑器不自动被内容撑高
                    autoHeightEnabled: false,
                    // 初始容器高度
                    initialFrameHeight: 200,
                    // 初始容器宽度
                    initialFrameWidth: '100%',
                    // 关闭自动保存
                    enableAutoSave: false,
                    // 自定义工具栏，需要额外选项可以参考ueditor.config.js
                    toolbars: [
                        [
                            'fullscreen', '|',
                            'bold', 'italic', 'underline', '|', 'fontsize', 'fontfamily', '|', 'insertimage',
                            '|',
                            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'kityformula'
                        ]
                    ]
                },
            }
        },
        mounted() {
            this.myConfig.serverUrl
        },
        methods: {
            ueditorReady(editorInstance) {
                this.ueditor = editorInstance;
                let UE = editorInstance;
                UE._bkGetActionUrl = UE.getActionUrl;
                UE.getActionUrl = action => {
                    if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
                        return this.$axios.baseUrl + '/ueditor/uploadimage?action=' + action; //此处写自定义的图片上传路径
                    } else if (action == 'uploadvideo') {
                        return '';
                    } else {
                        return this._bkGetActionUrl.call(this, action);
                    }
                }
            },
            set(){
                this.context=''
            }
        }
    }
</script>

<style>
</style>
